<template>
  <div class="app-container">
    <div class="qrCodeContainer" style="width: 450px; height: 50px; display: none; width: 100%">
      <h1 class="title" style="width: 480px; margin-left: 27%">{{ $t(`Print.RongyangGarment_Co_Ltd_OutboundOrder`) }}</h1>
      <div style="width: 95%; margin: auto">
        <div style="display: flex; width: 100%; font-size: 13px; justify-content: space-between">
          <h2 style="margin-left: 70px; font-size: 13px">{{ $t(`Print.OutboundOrderNumber`) }}:{{ slipNoList3[0]?.slipNo }}</h2>
          <h2 style="margin-left: 70px; font-size: 13px">{{ $t(`Print.OutboundDate`) }}:{{ slipNoList3[0]?.slipDate }}</h2>
          <h2 style="margin-left: 70px; font-size: 13px">{{ $t(`Print.OutboundDepartment`) }}:{{ slipNoList3[0]?.vendorName }}</h2>
          <h2 style="margin-left: 70px; font-size: 13px">{{ $t(`Print.OutboundReason`) }}:{{ slipNoList3[0]?.slipReason }}</h2>
          <h2 style="margin-left: 70px; font-size: 13px">{{ $t(`Print.TabulatedDate`) }}:{{ formatCurrentDateTime(currentDate) }}</h2>
        </div>

        <div style="width: 100%">
          <table style="width: 100%; font-size: 13px">
            <thead>
              <tr>
                <th>{{ $t(`Print.Directives`) }}</th>
                <th>{{ $t(`Print.MaterialColorKey`) }}</th>
                <th>{{ $t(`Print.MaterialName`) }}</th>
                <th>{{ $t(`Print.Specification`) }}</th>
                <th>{{ $t(`Print.Unit`) }}</th>
                <th>{{ $t(`Print.Quantity`) }}</th>
                <th>{{ $t(`Print.Remark`) }}</th>
              </tr>
            </thead>
            <tbody>
              <tr v-for="(iten1, index) in slipNoList3" :key="index">
                <td>{{ iten1.lotNo }}</td>

                <td>{{ iten1.mtlColor }}</td>
                <td>{{ iten1.mtlName }}</td>
                <td>{{ iten1.mtlSpec }}</td>
                <td>{{ iten1.mtlUnit }}</td>

                <td>{{ iten1.qty }}</td>

                <td>{{ iten1.remark }}</td>
                <!-- 更多的数据单元格 -->
              </tr>
              <!-- 更多的行 -->
            </tbody>
            <!-- 可选的 tfoot 部分 -->
          </table>

          <!-- <Table :tableHeader="tableHeader5" :tableData="slipNoList" /> -->
        </div>

        <div style="display: flex; justify-content: space-between; width: 85%; font-size: 17px; width: 80%; margin: auto">
          <h2 style="font-size: 13px">{{ $t(`Print.OrderCreator`) }}:{{ userInfo?.chiName }}</h2>
          <h2 style="font-size: 13px">{{ $t(`Print.Picker`) }}:</h2>
        </div>
      </div>
    </div>

    <Find :OriginalFilter="{ static: true }" :formList="formList1" @findClicked="findData" @Launchform="Launchform7" />
    <Find :OriginalFilter="{ static: true }" :searchImg="false" :formList="formList10" />
    <el-card style="margin-top: 15px" shadow="always" :body-style="{ padding: '5px' }">
      <div style="display: flex">
        <div style="width: 50%">
          <h1>{{ $t(`Print.PendingOutboundDetails`) }}</h1>
          <Table
            :isLoading="isLoading7"
            @confirmChange="confirmChange3"
            @currentRow="clicktogetdata"
            :tableHeader="tableHeader"
            :tableData="DetailsToBeReleasedMethodsTableDateList"
            :TableHeight="100"
            :outTableHeight="100"
          />
          <!--  -->
          <div style="display: flex; flex-wrap: wrap">
            <p style="margin-top: 10px">
              <span class="mr10">{{ $t(`Print.Specification`) }}</span>
              <el-input v-model="DetailsToBeReleasedMethodsFormList.mtSpace" placeholder="" size="small" clearable style="width: 110px" />
              <span style="margin-left: 45px" class="mr10">{{ $t(`Print.Unit`) }}</span>
              <el-input v-model="DetailsToBeReleasedMethodsFormList.mtUnit" placeholder="" size="small" clearable style="width: 100px" />
            </p>

            <p style="margin-top: 20px">
              <span class="mr10">{{ $t(`Print.MaterialColorKey`) }}</span>
              <el-input v-model="objectListInput.color" placeholder="" size="small" clearable style="width: 80px" />
              <span class="mr10">{{ $t(`Print.MaterialName`) }}</span>
              <el-input v-model="objectListInput.mtlName" placeholder="" size="small" clearable style="width: 230px" />
              <span class="mr10">{{ $t(`Print.Specification`) }}</span>
              <el-input v-model="objectListInput.mtlSpace" placeholder="" size="small" clearable style="width: 70px" />
              <span class="mr10">{{ $t(`Print.Unit`) }}</span>
              <el-input v-model="objectListInput.mtlUnit" placeholder="" size="small" clearable style="width: 50px" />
              <span class="mr10">{{ $t(`Print.InventoryLevels`) }}<</span>
              <el-input v-model="objectListInput.styQty" placeholder="" size="small" clearable style="width: 50px" />
            </p>
          </div>
        </div>
        <div style="width: 50%; margin-left: 10px">
          <h1>{{ $t(`Print.OtherMaterialOutboundDetails`) }}</h1>
          <Table
            :isLoading="isLoading13"
            @currentRow="clicktogetdata8"
            :tableHeader="tableHeader1"
            :tableData="OtherMaterialDeliveryDetailsMethodsTableDateList.dtos"
            :TableHeight="100"
            :outTableHeight="70"
          />

          <PageModule
            :PageData="{ total: totalOtherMaterial, pageSizeShow: true, buttonS: true }"
            :layout="'prev, pager'"
            @pageSizeChange="handleSizeChangeOtherMaterial"
            @pageChange="handleCurrentChangeOtherMaterial"
          />
        </div>
      </div>
    </el-card>

    <el-drawer v-model="drawer1" :direction="'ttb'" size="small" :with-header="false">
      <span @click="drawer1 = false" style="float: right; cursor: pointer; color: rgb(7, 7, 7)">X</span>
      <h1>{{ $t(`Print.QueryCondition`) }}</h1>
      <Find
        :OriginalFilter="{ static: true }"
        :searchImg="false"
        style="margin-top: 12px"
        :formList="formList6"
        @Launchform="Launchform"
        @findClicked="findData6"
      />
      <Table
        :isLoading="isLoading8"
        @currentRow1="currentRow1"
        style="margin-top: 15px; width: 60%"
        :tableHeader="tableHeader2"
        :tableData="GeneralMaterialsQueryMethodsTableDateList.dtos"
        :TableHeight="100"
        :outTableHeight="65"
      />
      <PageModule :PageData="{ total }" @pageSizeChange="handleSizeChange" @pageChange="handleCurrentChange" />
    </el-drawer>

    <el-drawer v-model="drawer2" :direction="'ttb'" size="small" :with-header="false">
      <span @click="drawer2 = false" style="float: right; cursor: pointer; color: rgb(7, 7, 7)">X</span>
      <h1>{{ $t(`Print.QueryCondition`) }}</h1>
      <Find
        :OriginalFilter="{ static: true }"
        :searchImg="false"
        style="margin-top: 12px"
        :formList="formList5"
        @findClicked="findDataK"
        @Launchform="Launchform1"
      />
      <div style="width: 70%">
        <Table
          :isLoading="isLoading9"
          @selectList="selectList5"
          @currentRow="currentRow7"
          :selection="true"
          style="margin-top: 15px"
          :tableHeader="tableHeader3"
          :tableData="InstructionDataMethodsTableDateList.dtos"
          :TableHeight="50"
          :outTableHeight="65"
        />
        <PageModule :PageData="{ total: totalT }" @pageSizeChange="handleSizeChangeT" @pageChange="handleCurrentChangeT" />
      </div>
      <h1>{{ $t(`Print.DetailedInformationOnTheAdheringMaterials`) }}</h1>
      <Table
        :isLoading="isLoading10"
        style="margin-top: 15px; width: 70%"
        :tableHeader="tableHeader5"
        :tableData="FitSubmaterialDetailsMethodsTableDateList"
        :TableHeight="50"
        :outTableHeight="65"
      />
    </el-drawer>

    <el-drawer v-model="drawer3" :direction="'ttb'" size="small" :with-header="false">
      <span @click="drawer3 = false" style="float: right; cursor: pointer; color: rgb(7, 7, 7)">X</span>
      <h1>{{ $t(`Print.QueryCondition`) }}</h1>
      <Find
        :OriginalFilter="{ static: true }"
        :searchImg="false"
        style="margin-top: 12px"
        @findClicked="findDataKlc"
        :formList="formList3"
        @Launchform="Launchform2"
      />
      <div style="width: 70%">
        <Table
          :isLoading="isLoading11"
          @selectList="selectList5"
          @currentRow="currentRow7"
          :selection="true"
          style="margin-top: 15px"
          :tableHeader="tableHeader6"
          :tableData="BulkMaterialMethodsTableDateList.dtos"
          :TableHeight="50"
          :outTableHeight="65"
        />
        <PageModule :PageData="{ total: totalTk }" @pageSizeChange="handleSizeChangeTk" @pageChange="handleCurrentChangeTk" />
      </div>
      <h1>{{ $t(`Print.DetailedInformationOnTheAdheringMaterials`) }}</h1>
      <Table
        :isLoading="isLoading10"
        style="margin-top: 15px; width: 70%"
        :tableHeader="tableHeader7"
        :tableData="FitSubmaterialDetailsMethodsTableDateList"
        :TableHeight="50"
        :outTableHeight="65"
      />
    </el-drawer>

    <el-drawer v-model="drawer5" :direction="'ttb'" size="small" :with-header="false">
      <span @click="drawer5 = false" style="float: right; cursor: pointer; color: rgb(7, 7, 7)">X</span>
      <h1>{{ $t(`Print.QueryCondition`) }}</h1>
      <Find
        :OriginalFilter="{ static: true }"
        @findClicked="findDataForm"
        :searchImg="false"
        style="margin-top: 12px"
        :formList="formList2"
        @Launchform="Launchform6"
      />
      <div style="width: 70%">
        <Table
          :isLoading="isLoading17"
          @currentRow1="currentRow5"
          style="margin-top: 15px"
          :tableHeader="tableHeader8"
          :tableData="materialDepotMethodsTableDateList.dtos"
          :TableHeight="100"
          :outTableHeight="65"
        />
        <PageModule :PageData="{ total: totalTkc }" @pageSizeChange="handleSizeChangeTkc" @pageChange="handleCurrentChangeTkc" />
      </div>
    </el-drawer>

    <el-drawer v-model="drawer7" :direction="'ttb'" size="small" :with-header="false">
      <span @click="drawer5 = false" style="float: right; cursor: pointer; color: rgb(7, 7, 7)">X</span>
      <h1>{{ $t(`Print.QueryCondition`) }}</h1>
      <Find
        :OriginalFilter="{ static: true }"
        @findClicked="findDataForm1"
        :searchImg="false"
        style="margin-top: 12px"
        :formList="formList7"
        @Launchform="Launchform9"
      />
      <div style="width: 70%">
        <Table
          :isLoading="isLoading14"
          @currentRow1="currentRow5"
          style="margin-top: 15px"
          :tableHeader="tableHeader9"
          :tableData="MaterialSubstitutionQueryMethodsTableDateList.dtos"
          :TableHeight="100"
          :outTableHeight="65"
        />
        <PageModule :PageData="{ total: totalMateria }" @pageSizeChange="handleSizeChangeMateria" @pageChange="handleCurrentChangeMateria" />
      </div>
    </el-drawer>

    <el-drawer v-model="drawer6" :direction="'ttb'" size="small" :with-header="false">
      <span @click="drawer5 = false" style="float: right; cursor: pointer; color: rgb(7, 7, 7)">X</span>
      <h1>{{ $t(`Print.QueryCondition`) }}</h1>
      <Find
        :OriginalFilter="{ static: true }"
        @findClicked="findData7"
        :searchImg="false"
        style="margin-top: 12px"
        :formList="formList8"
        @Launchform="Launchform10"
      />
      <div style="width: 70%">
        <Table
          :isLoading="isLoading15"
          @currentRow="clicktogetdata10"
          style="margin-top: 15px"
          :tableHeader="tableHeader10"
          :tableData="MaterialSubstitutionMatercListMethodsTableDateList.dtos"
          :TableHeight="100"
          :outTableHeight="65"
        />
        <PageModule
          :PageData="{ total: totalSubstitution }"
          @pageSizeChange="handleSizeChangeSubstitution"
          @pageChange="handleCurrentChangeSubstitution"
        />
      </div>
    </el-drawer>
  </div>
</template>
<script lang="ts">
import { defineComponent } from 'vue'
import { DepartmentAllInquiry } from '@/api/WarehouseDepartment/FactoryStorage/ReplenishmentInvoicing'
import LoginWork from '@/utils/LoginWork'
import JMessage from '@/utils/JMessage'
export default defineComponent({
  name: 'OtherOutboundOperations'
})
</script>
<script lang="ts" setup>
import { i18n, Jzhcn } from '@/i18n'
import { ref, onMounted, watch } from 'vue'
import {
  MaterialSubstitutionMatercList,
  BlockDeletion,
  MaterialSubstitutionQuery,
  FitSubmaterialDetails,
  ToBeAddedInStorage,
  BatchProcessingOutOfStorage,
  ReasonForDelivery,
  OtherMaterialDeliveryDetails,
  DetailsToBeReleased,
  materialDepot,
  BulkMaterial,
  materialsClassification,
  InstructionDataList,
  GeneralMaterialsQuery,
  MaterialCategory
} from '@/api/WarehouseDepartment/FactoryStorage/OtherOutboundOperations'
import type {
  MaterialSubstitutionMatercListInterface,
  MaterialSubstitutionMatercListParms,
  MaterialSubstitutionQueryInterface,
  MaterialSubstitutionQueryParms,
  BatchProcessingOutOfStorageParms,
  OtherMaterialDeliveryDetailsInterface,
  OtherMaterialDeliveryDetailsParms,
  DetailsToBeReleasedInterface,
  materialDepotParms,
  materialDepotInterface,
  BulkMaterialParms,
  BulkMaterialInterface,
  InstructionDataPamrs,
  InstructionDataInterface,
  GeneralMaterialsQueryPamrs,
  GeneralMaterialsQueryInterface
} from '@/api/WarehouseDepartment/FactoryStorage/OtherOutboundOperations'
import { InstructionData } from '@/api/WarehouseDepartment/FactoryStorage/StorageOtherMaterials'
import { VendorData } from '@/api/WarehouseDepartment/FactoryStorage/TemporaryReceiptStorage'
import { ElMessage } from 'element-plus'
import { ElMessageBox } from 'element-plus'

const slipNoList3 = ref<any>([])

const printQRCode = () => {
  const qrCodeContainer = document.querySelector<any>('.qrCodeContainer')
  if (qrCodeContainer) {
    // 临时显示 .qrCodeContainer 以获取其内容
    qrCodeContainer.style.display = 'block'

    const printWindow = window.open('', '_blank')
    printWindow!.document.write(`
      <!DOCTYPE html>
      <html>
        <head>
          <title>打印指令领料作业</title>
          <link rel="stylesheet" type="text/css" href="print.css" media="print">
          <style>
            body, html {
              margin: 0;
              padding: 0;
            }
            @page {
              size: auto; 
              margin: 3mm;
            }
            @media print {
                /* 打印时的样式 */
             
                
                /* 其他打印样式 */
            }
            h2 {
                    margin-left: initial; /* 或者设置适合打印的左边距 */
                    page-break-inside: avoid; /* 避免在h2元素内部分页 */
                }
               

            table, th, td {
                    border: 1px solid black; 
                    border-collapse: collapse; 
                    text-align: center;
                  }
                  th, td {
                    padding: 5px; /* 设置内边距 */
                    text-align: left; /* 设置文本对齐方式 */
                    text-align: center;
                    font-size:11px
                  }
                  .double-line {
                    border-top: 2px dashed red; 
                    border-bottom: 2px dashed red; 
                    text-align: center;
                  }
           
            /* 可以在这里添加更多自定义的打印样式 */
          </style>
        </head>
        <body>
    `)

    // 将 .qrCodeContainer 的内容复制到打印窗口的 body 中
    const cloneContainer = qrCodeContainer.cloneNode(true)
    printWindow!.document.body.appendChild(cloneContainer)

    printWindow!.document.write(`
        </body>
      </html>
    `)
    printWindow!.document.close()

    // 开始打印
    printWindow!.print()

    // 打印完成后，可以恢复 .qrCodeContainer 的原始显示状态
    qrCodeContainer.style.display = 'none'
  }
}

// 日期
const formatCurrentDateTime = (date?: Date) => {
  const year = date!.getFullYear()
  const month = String(date!.getMonth() + 1).padStart(2, '0') // 使用padStart确保月份是两位数
  const day = String(date!.getDate()).padStart(2, '0') // 使用padStart确保日期是两位数
  const hours = String(date!.getHours()).padStart(2, '0') // 小时
  const minutes = String(date!.getMinutes()).padStart(2, '0') // 分钟
  const seconds = String(date!.getSeconds()).padStart(2, '0') // 秒

  // 返回格式化的日期时间字符串
  return `${year}-${month}-${day} ${hours}:${minutes}:${seconds}`
}

const formatCurrentDateTime1 = (date?: Date) => {
  const year = date!.getFullYear()
  const month = String(date!.getMonth() + 1).padStart(2, '0') // 使用padStart确保月份是两位数
  const day = String(date!.getDate()).padStart(2, '0') // 使用padStart确保日期
  // 返回格式化的日期时间字符串
  return `${year}-${month}-${day}`
}

const currentDate = ref<any>(new Date())

const isLoading7 = ref(false)
const isLoading8 = ref(false)
const isLoading9 = ref(false)
const isLoading10 = ref(false)
const isLoading11 = ref(false)
const isLoading13 = ref(false)
const isLoading14 = ref(false)
const isLoading15 = ref(false)
const isLoading17 = ref(false)

const formList1 = ref([
  {
    type: 'button',
    checkboxLabel: '通用材料'
  },
  {
    type: 'button',
    checkboxLabel: '指令材料'
  },
  {
    type: 'button',
    checkboxLabel: '型体材料'
  },
  {
    type: 'button',
    checkboxLabel: '贴合子材料'
  },
  {
    type: 'button',
    checkboxLabel: '材料库'
  },
  {
    type: 'dateSingle',
    dateLabel: '出库日期',
    dateValue: '',
    disabled: true
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '部门',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '厂商',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '出库原因',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'button',
    checkboxLabel: '出库批处理'
  },
  {
    type: 'button',
    checkboxLabel: '打印'
  },
  {
    type: 'button',
    checkboxLabel: '打印(连打)'
  },
  {
    type: 'input',
    inputPlaceholder: '请输入出库单号',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '出库原因 ',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'date',
    dateLabel: '出库日期',
    dateValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入材料名称',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '替代材料查询'
  },
  {
    type: 'button',
    checkboxLabel: '整单删除'
  },
  {
    type: 'button',
    checkboxLabel: '材料替代'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList5 = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入指令',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入型体',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '分类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '材料名称',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '待出批处理'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList3 = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入型体',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '请输入颜色',
    inputValue: ''
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '分类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '材料名称',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '待出批处理'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList2 = ref([
  {
    type: 'select',
    selectValue: '',
    selectP: '大类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '中类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '小类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '名称1',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '名称2',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '名称3',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '颜色',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '规格',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '单位',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList6 = ref([
  {
    type: 'select',
    selectValue: '',
    selectP: '材料大类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'select',
    selectValue: '',
    selectP: '材料子类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '请输入材料名称',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList7 = ref([
  {
    type: 'input',
    inputPlaceholder: '请输入单据号',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '材料名称(替代前)',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '材料名称(替代后)',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList8 = ref([
  {
    type: 'select',
    selectValue: '',
    selectP: '分类',
    selectLabel: '',
    selectOptions: []
  },
  {
    type: 'input',
    inputPlaceholder: '材料名称',
    inputValue: ''
  },
  {
    type: 'input',
    inputPlaceholder: '材料颜色',
    inputValue: ''
  },
  {
    type: 'button',
    checkboxLabel: '确认'
  },
  {
    type: 'button',
    checkboxLabel: '置空',
    bgColor: '#1890FF'
  }
])

const formList10 = ref([
  {
    type: 'input',
    inputPlaceholder: '',
    inputValue: '',
    inputLabel: '部门名称'
  },
  {
    type: 'input',
    inputPlaceholder: '',
    inputValue: '',
    inputLabel: '物料编号'
  },
  {
    type: 'input',
    inputPlaceholder: '',
    inputValue: '',
    inputLabel: '仓管员'
  }
])

const EvaluatesTheArrayReturnValue = (ArrayList: any) => {
  return ArrayList.map((item: any, index: any) => {
    return {
      optionKey: index,
      optionValue: item,
      optionLabel: item
    }
  })
}

// 修改
const confirmChange3 = async (row: any) => {
  const result = await LoginWork.put<any, any>(`/pcFactorStockQuery/otherMtlWaitStockUpdate2`, [row])
  if (result.code === 200) {
    DetailsToBeReleasedMethods()
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 材料替代
const clearFormList7 = () => {
  formList8.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    // Add other conditions for different form item types
  })
}

const mtlNo1 = ref()

const objectList = ref()

const objectListInput = ref({
  color: '',
  mtlName: '',
  mtlSpace: '',
  mtlUnit: '',
  styQty: ''
})

const clicktogetdata10 = (row: any) => {
  mtlNo1.value = row
}

const findData7 = (row: any) => {
  if (row === '确认') {
    if (objectList.value !== undefined && mtlNo1.value !== undefined) {
      objectList.value.mtlNo2 = mtlNo1.value.mtlNo
      objectListInput.value.color = mtlNo1.value.mtlColor
      objectListInput.value.mtlName = mtlNo1.value.mtlName
      objectListInput.value.mtlSpace = mtlNo1.value.mtlSpec
      objectListInput.value.mtlUnit = mtlNo1.value.mtlUnit
      objectListInput.value.styQty = mtlNo1.value.stkQty
      JMessage.success('物料编码替换成功')
    } else {
      JMessage.warning('请选择正确的物料编码')
    }
  }
  if (row === '置空') {
    clearFormList7()
  }
}

const Launchform10 = (row: any) => {
  MaterialSubstitutionMatercListMethodsParms.value.mtlType = row[0].selectValue.split(' ')[0]
  MaterialSubstitutionMatercListMethodsParms.value.mtlName = row[1].inputValue
  MaterialSubstitutionMatercListMethodsParms.value.mtlColor = row[1].inputValue
}

const drawer6 = ref(false)

const MaterialSubstitutionMatercListMethodsParms = ref<MaterialSubstitutionMatercListParms>({
  mtlColor: '',
  mtlName: '',
  mtlType: '',
  pageNum: 1,
  pageSize: 40
})

const MaterialSubstitutionMatercListMethodsTableDateList = ref<MaterialSubstitutionMatercListInterface>({
  dtos: []
})

const MaterialSubstitutionMatercListMethods = async () => {
  isLoading15.value = true
  const result = await MaterialSubstitutionMatercList(MaterialSubstitutionMatercListMethodsParms.value)
  MaterialSubstitutionMatercListMethodsTableDateList.value.dtos = result.dtos
  totalSubstitution.value = result.total!
  isLoading15.value = false
}

const totalSubstitution = ref(0)

const handleSizeChangeSubstitution = (val: number) => {
  MaterialSubstitutionQueryPamrs.value.pageSize = val
  MaterialSubstitutionQueryMethods()
}

const handleCurrentChangeSubstitution = (val: number) => {
  MaterialSubstitutionQueryPamrs.value.pageNum = val
  MaterialSubstitutionQueryMethods()
}

// 整单删除
const slipNok = ref<string>('')

const BlockDeletionMethods = async () => {
  const result = await BlockDeletion(slipNok.value)
  if (result.code === 200) {
    OtherMaterialDeliveryDetailsMethods()
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

const handleClose3 = (_done?: () => void) => {
  ElMessageBox.confirm('确定要删除该数据吗')
    .then(() => {
      BlockDeletionMethods()
    })
    .catch(() => {})
}

// 材料替代查询
const clearFormList6 = () => {
  formList7.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    // Add other conditions for different form item types
  })
}

const findDataForm1 = (row: any) => {
  if (row === '置空') {
    clearFormList6()
  }
}

const Launchform9 = (row: any) => {
  MaterialSubstitutionQueryPamrs.value.slipNo = row[0].inputValue
  MaterialSubstitutionQueryPamrs.value.mtlName1 = row[1].inputValue
  MaterialSubstitutionQueryPamrs.value.mtlName2 = row[2].inputValue
  MaterialSubstitutionQueryMethods()
}

const drawer7 = ref(false)

const MaterialSubstitutionQueryPamrs = ref<MaterialSubstitutionQueryParms>({
  mtlName1: '',
  mtlName2: '',
  pageNum: 1,
  pageSize: 40,
  slipNo: ''
})

const MaterialSubstitutionQueryMethodsTableDateList = ref<MaterialSubstitutionQueryInterface>({
  dtos: []
})

const MaterialSubstitutionQueryMethods = async () => {
  isLoading14.value = true
  const result = await MaterialSubstitutionQuery(MaterialSubstitutionQueryPamrs.value)
  MaterialSubstitutionQueryMethodsTableDateList.value.dtos = result.dtos
  totalMateria.value = result.total!
  isLoading14.value = false
}

const totalMateria = ref(0)

const handleSizeChangeMateria = (val: number) => {
  MaterialSubstitutionQueryPamrs.value.pageSize = val
  MaterialSubstitutionQueryMethods()
}

const handleCurrentChangeMateria = (val: number) => {
  MaterialSubstitutionQueryPamrs.value.pageNum = val
  MaterialSubstitutionQueryMethods()
}

// 贴合子材料明细
const FitSubmaterialDetailsMethodsParms = ref({
  mtlNo: ''
})

const FitSubmaterialDetailsMethodsTableDateList = ref([])

const FitSubmaterialDetailsMethods = async () => {
  isLoading10.value = true
  const result = await FitSubmaterialDetails(FitSubmaterialDetailsMethodsParms.value)
  FitSubmaterialDetailsMethodsTableDateList.value = result.map((item: any) => {
    if (item.purFlag === 'Y') {
      item.purFlag = true
    }
    return item
  })
  isLoading10.value = false
}

// 待入库新增
const ToBeAddedInStorageMethodsParms = ref<any>([])

const typeNumber = ref<number>()

const ToBeAddedInStorageMethods = async () => {
  const result = await ToBeAddedInStorage(typeNumber.value as number, ToBeAddedInStorageMethodsParms.value)
  if (result.code === 200) {
    ToBeAddedInStorageMethodsParms.value = []
    DetailsToBeReleasedMethods()
    JMessage.success(result.message)
  } else {
    ToBeAddedInStorageMethodsParms.value = []
    JMessage.error(result.message)
  }
}

// 出库批处理
const Launchform7 = (row: any) => {
  BatchProcessingOutOfStorageMethodsPamrs.value.slipReason = row[8].selectValue?.split(' ')[0]?.trim()
  BatchProcessingOutOfStorageMethodsPamrs.value.deptNo = row[6].selectValue?.split(' ')[0]?.trim()

  BatchProcessingOutOfStorageMethodsPamrs.value.slipDate = formatCurrentDateTime1(currentDate.value)

  BatchProcessingOutOfStorageMethodsPamrs.value.deptName = row[6].selectValue?.split(' ')[1]?.trim()
  if (BatchProcessingOutOfStorageMethodsPamrs.value.deptNo === undefined || BatchProcessingOutOfStorageMethodsPamrs.value.deptName === undefined) {
    BatchProcessingOutOfStorageMethodsPamrs.value.deptNo = row[7].selectValue?.split(' ')[0]?.trim()
    BatchProcessingOutOfStorageMethodsPamrs.value.deptName = row[7].selectValue?.split(' ')[1]?.trim()
  }

  OtherMaterialDeliveryDetailsMethodsParms.value.lotNo = row[15].inputValue
  OtherMaterialDeliveryDetailsMethodsParms.value.mtlName = row[16].inputValue
  OtherMaterialDeliveryDetailsMethodsParms.value.slipDateEnd = row[14].dateValue[1]
  OtherMaterialDeliveryDetailsMethodsParms.value.slipDateStart = row[14].dateValue[0]
  OtherMaterialDeliveryDetailsMethodsParms.value.slipReason = row[13].selectValue
  OtherMaterialDeliveryDetailsMethodsParms.value.slipNo = row[12].inputValue
  OtherMaterialDeliveryDetailsMethods()
}

const BatchProcessingOutOfStorageMethodsPamrs = ref<any>({
  slipDate: '',
  deptName: '',
  deptNo: '',
  slipReason: ''
})

const BatchProcessingOutOfStorageMethods = async () => {
  const result = await BatchProcessingOutOfStorage(BatchProcessingOutOfStorageMethodsPamrs.value)
  if (result.code === 200) {
    OtherMaterialDeliveryDetailsMethods()
    BatchProcessingOutOfStorageMethodsPamrs.value.deptName = ''
    BatchProcessingOutOfStorageMethodsPamrs.value.deptNo = ''
    BatchProcessingOutOfStorageMethodsPamrs.value.slipReason = ''
    JMessage.success(result.message)
  } else {
    JMessage.error(result.message)
  }
}

// 部门
const DepartmentAllInquiryMethods = async () => {
  let NewArray = []
  const result = await DepartmentAllInquiry()
  NewArray = result.reduce((arr: any, item: any) => {
    if (item.deptNo && item.deptName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.deptNo + ' ' + item.deptName)
    }
    return arr
  }, [])
  formList1.value[6].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

// 厂商
const VendorQueryDateList = async () => {
  let NewArray = []
  const result = await VendorData()
  console.log(result)
  NewArray = result.vendor.reduce((arr: any, item: any) => {
    if (item.vendorNo && item.vendorName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.vendorNo + ' ' + item.vendorName)
    }
    return arr
  }, [])
  formList1.value[7].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

// 其他材料出库明细
const OtherMaterialDeliveryDetailsMethodsParms = ref<OtherMaterialDeliveryDetailsParms>({
  lotNo: '',
  mtlName: '',
  pageNum: 1,
  pageSize: 40,
  slipDateEnd: '',
  slipDateStart: '',
  slipNo: '',
  slipReason: ''
})

const OtherMaterialDeliveryDetailsMethodsTableDateList = ref<OtherMaterialDeliveryDetailsInterface>({
  dtos: []
})

const OtherMaterialDeliveryDetailsMethods = async () => {
  isLoading13.value = true
  const result = await OtherMaterialDeliveryDetails(OtherMaterialDeliveryDetailsMethodsParms.value)
  OtherMaterialDeliveryDetailsMethodsTableDateList.value.dtos = result.dtos
  totalOtherMaterial.value = result.total!
  if (result.dtos.length !== 0) {
    formList10.value[0].inputValue = result.dtos[0].deptName
    formList10.value[1].inputValue = result.dtos[0].mtlNo
    formList10.value[2].inputValue = result.dtos[0].sysUser
  }
  isLoading13.value = false
}

const clicktogetdata8 = (row: any) => {
  slipNok.value = row.slipNo
  formList10.value[0].inputValue = row.deptName
  formList10.value[1].inputValue = row.mtlNo
  formList10.value[2].inputValue = row.sysUser
  slipNoList3.value = OtherMaterialDeliveryDetailsMethodsTableDateList.value.dtos.filter((item: any) => row.slipNo === item.slipNo)
}

const ReasonForDeliveryMethods = async () => {
  const result = await ReasonForDelivery()
  console.log(result)
  formList1.value[13].selectOptions = EvaluatesTheArrayReturnValue(result)
  formList1.value[8].selectOptions = EvaluatesTheArrayReturnValue(result)
}

const totalOtherMaterial = ref(0)

const handleSizeChangeOtherMaterial = (val: number) => {
  materialDepotMethodsPamrs.value.pageSize = val
  materialDepotMethods()
}

const handleCurrentChangeOtherMaterial = (val: number) => {
  materialDepotMethodsPamrs.value.pageNum = val
  materialDepotMethods()
}

// 待出库明细
const DetailsToBeReleasedMethodsTableDateList = ref<DetailsToBeReleasedInterface[]>()

const DetailsToBeReleasedMethodsFormList = ref({
  mtSpace: '',
  mtUnit: ''
})

const DetailsToBeReleasedMethods = async () => {
  isLoading7.value = true
  const result = await DetailsToBeReleased()
  if (result !== null) {
    DetailsToBeReleasedMethodsTableDateList.value = result.map((item: any) => {
      item.change = 'Y'
      return item
    })
  }

  if (result.length > 0) {
    const { mtSpace, mtUnit, mtlNo } = result[0]
    DetailsToBeReleasedMethodsFormList.value.mtSpace = mtSpace
    DetailsToBeReleasedMethodsFormList.value.mtUnit = mtUnit
  }
  isLoading7.value = false
}

const clicktogetdata = (row: any) => {
  const { mtSpace, mtUnit, mtlNo } = row
  DetailsToBeReleasedMethodsFormList.value.mtSpace = mtSpace
  DetailsToBeReleasedMethodsFormList.value.mtUnit = mtUnit
  objectList.value = row
}

// 材料库
const drawer5 = ref(false)

const clearFormList5 = () => {
  formList2.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    // Add other conditions for different form item types
  })
}

const findDataForm = (row: string) => {
  if (row === '置空') {
    clearFormList5()
  }
}

const currentRow5 = (row: any) => {
  ToBeAddedInStorageMethodsParms.value.push(row as any)
  ToBeAddedInStorageMethods()
}

const materialDepotMethodsPamrs = ref<materialDepotParms>({
  mtlColor: '',
  mtlName_1: '',
  mtlName_2: '',
  mtlName_3: '',
  mtlSpec: '',
  mtlTypeL: '',
  mtlTypeM: '',
  mtlTypeS: '',
  mtlUnit: '',
  pageNum: 1,
  pageSize: 40
})

const materialDepotMethodsTableDateList = ref<materialDepotInterface>({
  dtos: []
})

const materialDepotMethods = async () => {
  isLoading17.value = true
  const result = await materialDepot(materialDepotMethodsPamrs.value)
  materialDepotMethodsTableDateList.value.dtos = result.dtos
  totalTkc.value = result.total!
  isLoading17.value = false
}

// 指令材料回显
const Command = ref<string>('')

const Command1 = ref<string>('')

watch(Command, () => {
  CommandMaterialEchoData1()
})

watch(Command1, () => {
  CommandMaterialEchoData2()
})

const CommandMaterialEchoData = async () => {
  const result = await InstructionData(Command.value)
  let NewArray1 = []

  NewArray1 = result.reduce((arr: any, item: any) => {
    if (item.typeNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.typeNo + ' ' + item.typeName)
    }
    return arr
  }, [])
  formList2.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArray1)
}

const CommandMaterialEchoData1 = async () => {
  const result = await InstructionData(Command.value)
  let NewArray1 = []

  NewArray1 = result.reduce((arr: any, item: any) => {
    if (item.typeNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.typeNo + ' ' + item.typeName)
    }
    return arr
  }, [])
  formList2.value[1].selectOptions = EvaluatesTheArrayReturnValue(NewArray1)
}

const CommandMaterialEchoData2 = async () => {
  const result = await InstructionData(Command1.value)
  let NewArray1 = []

  NewArray1 = result.reduce((arr: any, item: any) => {
    if (item.typeNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.typeNo + ' ' + item.typeName)
    }
    return arr
  }, [])
  formList2.value[2].selectOptions = EvaluatesTheArrayReturnValue(NewArray1)
}

const Launchform6 = (row: any) => {
  if (row[0].selectValue?.split(' ')[0]?.trim() !== '') {
    Command.value = row[0].selectValue?.split(' ')[0]?.trim()
  }
  if (row[1].selectValue?.split(' ')[0]?.trim() !== '') {
    Command1.value = row[1].selectValue?.split(' ')[0]?.trim()
  }

  materialDepotMethodsPamrs.value.mtlTypeL = row[0].selectValue?.split(' ')[0]?.trim()
  materialDepotMethodsPamrs.value.mtlTypeM = row[1].selectValue?.split(' ')[0]?.trim()
  materialDepotMethodsPamrs.value.mtlTypeS = row[2].selectValue?.split(' ')[0]?.trim()
  materialDepotMethodsPamrs.value.mtlName_1 = row[3].inputValue
  materialDepotMethodsPamrs.value.mtlName_2 = row[4].inputValue
  materialDepotMethodsPamrs.value.mtlName_3 = row[5].inputValue
  materialDepotMethodsPamrs.value.mtlColor = row[6].inputValue
  materialDepotMethodsPamrs.value.mtlSpec = row[7].inputValue
  materialDepotMethodsPamrs.value.mtlUnit = row[8].inputValue
  materialDepotMethods()
}

const totalTkc = ref(0)

const handleSizeChangeTkc = (val: number) => {
  materialDepotMethodsPamrs.value.pageSize = val
  materialDepotMethods()
}

const handleCurrentChangeTkc = (val: number) => {
  materialDepotMethodsPamrs.value.pageNum = val
  materialDepotMethods()
}

// 型体材料
const drawer3 = ref(false)

const clearFormList3 = () => {
  formList3.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    // Add other conditions for different form item types
  })
}

const findDataKlc = (count: string) => {
  if (count === '待出批处理') {
    if (ToBeAddedInStorageMethodsParms.value.length === 0) {
      JMessage.warning('请选择需要处理的数据')
    } else {
      ToBeAddedInStorageMethods()
    }
  }
  if (count === '置空') {
    clearFormList3()
  }
}

const BulkMaterialMethodsParms = ref<BulkMaterialParms>({
  mtlName: '',
  mtlTypeNo: '',
  pageNum: 1,
  pageSize: 40,
  styleColor: '',
  styleNo: ''
})

const BulkMaterialMethodsTableDateList = ref<BulkMaterialInterface>({
  dtos: []
})

const BulkMaterialMethods = async () => {
  isLoading11.value = true
  const result = await BulkMaterial(BulkMaterialMethodsParms.value)
  BulkMaterialMethodsTableDateList.value.dtos = result.dtos
  totalTk.value = result.total!
  if (result.dtos.length > 0) {
    const { mtlNo } = result.dtos[0]
    FitSubmaterialDetailsMethodsParms.value.mtlNo = mtlNo
    FitSubmaterialDetailsMethods()
  }
  isLoading11.value = false
}

const Launchform2 = (row: any) => {
  BulkMaterialMethodsParms.value.styleNo = row[0].inputValue
  BulkMaterialMethodsParms.value.styleColor = row[1].inputValue
  BulkMaterialMethodsParms.value.mtlTypeNo = row[2].selectValue.split(' ')[0]
  BulkMaterialMethodsParms.value.mtlName = row[3].inputValue
  BulkMaterialMethods()
}

const totalTk = ref(0)

const handleSizeChangeTk = (val: number) => {
  BulkMaterialMethodsParms.value.pageSize = val
  BulkMaterialMethods()
}

const handleCurrentChangeTk = (val: number) => {
  BulkMaterialMethodsParms.value.pageNum = val
  GeneralMaterialsQueryMethods()
}

// 指令材料
const selectList5 = (row: any) => {
  ToBeAddedInStorageMethodsParms.value = row.map((item: any) => {
    item.color = item.styleColor
    item.style = item.styleNo
    return item
  })
}

const clearFormList2 = () => {
  formList5.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
  })
}

const findDataK = (count: any) => {
  if (count === '待出批处理') {
    if (ToBeAddedInStorageMethodsParms.value.length === 0) {
      JMessage.warning('请选择需要处理的数据')
    } else {
      ToBeAddedInStorageMethods()
    }
  }
  if (count === '置空') {
    clearFormList2()
    console.log(11)
  }
}

const drawer2 = ref(false)

const currentRow7 = (row: any) => {
  const { mtlNo } = row
  FitSubmaterialDetailsMethodsParms.value.mtlNo = mtlNo
  FitSubmaterialDetailsMethods()
}

const materialsClassificationMethods = async () => {
  let NewArray = []
  const result = await materialsClassification()
  NewArray = result.reduce((arr: any, item: any) => {
    if (item.typeNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.typeNo + ' ' + item.typeName)
    }
    return arr
  }, [])
  formList5.value[2].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
  formList3.value[2].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
  formList8.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

const InstructionDataMethodsParms = ref<InstructionDataPamrs>({
  lotNo: '',
  mtlName: '',
  pageNum: 1,
  pageSize: 40,
  style: '',
  typeNo: ''
})

const InstructionDataMethodsTableDateList = ref<InstructionDataInterface>({
  dtos: []
})

const InstructionDataMethods = async () => {
  isLoading9.value = true
  const result = await InstructionDataList(InstructionDataMethodsParms.value)
  InstructionDataMethodsTableDateList.value.dtos = result.dtos
  totalT.value = result.total!
  if (result.dtos.length > 0) {
    const { mtlNo } = result.dtos[0]
    FitSubmaterialDetailsMethodsParms.value.mtlNo = mtlNo
    FitSubmaterialDetailsMethods()
  }
  isLoading9.value = false
}

const Launchform1 = (row: any) => {
  InstructionDataMethodsParms.value.lotNo = row[0].inputValue
  InstructionDataMethodsParms.value.style = row[1].inputValue
  InstructionDataMethodsParms.value.typeNo = row[2].selectValue.split(' ')[0]
  InstructionDataMethodsParms.value.mtlName = row[3].inputValue
  InstructionDataMethods()
}

const totalT = ref(0)

const handleSizeChangeT = (val: number) => {
  InstructionDataMethodsParms.value.pageSize = val
  InstructionDataMethods()
}

const handleCurrentChangeT = (val: number) => {
  InstructionDataMethodsParms.value.pageNum = val
  InstructionDataMethods()
}

// 材料大类子类
const currentRow1 = (row: any) => {
  ToBeAddedInStorageMethodsParms.value.push(row as any)
  ToBeAddedInStorageMethods()
}

const MaterialCategoryMethodsQuery = ref('')

const MaterialCategoryMethods = async () => {
  let NewArray = []
  const result = await MaterialCategory(MaterialCategoryMethodsQuery.value)
  NewArray = result.reduce((arr: any, item: any) => {
    if (item.typeNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.typeNo + ' ' + item.typeName)
    }
    return arr
  }, [])
  formList6.value[0].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

const MaterialCategoryMethods1 = async () => {
  let NewArray = []
  const result = await MaterialCategory(MaterialCategoryMethodsQuery.value)
  NewArray = result.reduce((arr: any, item: any) => {
    if (item.typeNo && item.typeName) {
      // 只添加非空的 typeName 和 typeNo
      arr.push(item.typeNo + ' ' + item.typeName)
    }
    return arr
  }, [])
  formList6.value[1].selectOptions = EvaluatesTheArrayReturnValue(NewArray)
}

watch(MaterialCategoryMethodsQuery, () => {
  MaterialCategoryMethods1()
})

const Launchform = (row: any) => {
  isLoading.value = true
  MaterialCategoryMethodsQuery.value = row[0].selectValue.split(' ')[0]
  GeneralMaterialsQueryMethodsParms.value.mtlTypeL = row[0].selectValue.split(' ')[0]
  GeneralMaterialsQueryMethodsParms.value.mtlTypeS = row[1].selectValue.split(' ')[0]
  GeneralMaterialsQueryMethodsParms.value.mtlName = row[2].inputValue
  GeneralMaterialsQueryMethods()
}

const clearFormList1 = () => {
  formList6.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    // Add other conditions for different form item types
  })
}

const findData6 = (count: string) => {
  if (count === '置空') {
    clearFormList1()
  }
}

// 通用材料
const drawer1 = ref(false)

const isLoading = ref(true)

const GeneralMaterialsQueryMethodsParms = ref<GeneralMaterialsQueryPamrs>({
  mtlName: '',
  mtlTypeL: '',
  mtlTypeS: '',
  pageNum: 1,
  pageSize: 40
})

const GeneralMaterialsQueryMethodsTableDateList = ref<GeneralMaterialsQueryInterface>({
  dtos: []
})

const GeneralMaterialsQueryMethods = async () => {
  isLoading8.value = true
  const result = await GeneralMaterialsQuery(GeneralMaterialsQueryMethodsParms.value)
  GeneralMaterialsQueryMethodsTableDateList.value.dtos = result.dtos
  total.value = result.total!
  isLoading8.value = false
}

const total = ref(0)

const handleSizeChange = (val: number) => {
  isLoading.value = true
  GeneralMaterialsQueryMethodsParms.value.pageSize = val
  GeneralMaterialsQueryMethods()
}

const handleCurrentChange = (val: number) => {
  isLoading.value = true
  GeneralMaterialsQueryMethodsParms.value.pageNum = val
  GeneralMaterialsQueryMethods()
}

// 表格数据

const tableHeader = ref([
  {
    label: '指令',
    prop: 'lotNo',
    change: true
  },
  {
    label: '物料编码',
    prop: 'mtlNo',
    change: true
  },
  {
    label: '材料颜色',
    prop: 'mtlColor',
    change: true
  },
  {
    label: '材料名称',
    prop: 'mtlName',
    change: true
  },
  {
    label: '替代物料编码',
    prop: 'mtlNo2',
    change: true
  },
  {
    label: '数量',
    prop: 'qty'
  },
  {
    label: '库存量',
    prop: 'stkQty',
    change: true
  },
  {
    label: '备注',
    prop: 'remark'
  }
])

const tableHeader1 = ref([
  {
    label: '出库单号',
    prop: 'slipNo'
  },
  {
    label: '出库日期',
    prop: 'slipDate'
  },
  {
    label: '出库原因',
    prop: 'slipReason'
  },
  {
    label: '指令',
    prop: 'lotNo'
  },
  {
    label: '材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '数量',
    prop: 'qty'
  },
  {
    label: '备注',
    prop: 'remark'
  }
])

const tableHeader2 = ref([
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '材料类型',
    prop: 'mtlTypeNo'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '颜色',
    prop: 'mtlColor'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '库存量',
    prop: 'stkQty'
  }
])

const tableHeader3 = ref([
  {
    label: '指令',
    prop: 'lotNo'
  },
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '用量',
    prop: 'ttlUsage'
  },
  {
    label: '库存量',
    prop: 'stkQty'
  }
])

const tableHeader5 = ref([
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '子材料名称',
    prop: 'mtlName'
  },
  {
    label: '材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '比例',
    prop: 'percent'
  },
  {
    label: '是否请购',
    type: 'checkbox',
    prop: 'financeFlag',
    width: '69px'
  }
])

const tableHeader6 = ref([
  {
    label: '货号',
    prop: 'styleNo'
  },
  {
    label: '颜色',
    prop: 'styleColor'
  },
  {
    label: '序号',
    prop: 'seqNo'
  },
  {
    label: '部位',
    prop: 'mtlName'
  },
  {
    label: '段',
    prop: 'segment'
  },
  {
    label: '分类名称',
    prop: 'mtlType'
  },
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '库存量',
    prop: 'stkQty'
  }
])

const tableHeader7 = ref([
  {
    label: '物料编码',
    prop: 'lotNo'
  },
  {
    label: '子材料名称',
    prop: 'mtlNo'
  },
  {
    label: '子材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '规格',
    prop: 'mtlName'
  },
  {
    label: '单位',
    prop: 'mtlSpec'
  },
  {
    label: '比例',
    prop: 'mtlUnit'
  },
  {
    label: '选择',
    type: 'checkbox',
    prop: 'purFlag',
    width: '69px'
  }
])

const tableHeader8 = ref([
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '颜色',
    prop: 'mtlColor'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  }
])

const tableHeader9 = ref([
  {
    label: '出库原因',
    prop: 'outType'
  },
  {
    label: '单据号',
    prop: 'slipNo'
  },
  {
    Multistage: true,
    label: '材料替代前',
    children: [
      {
        label: '物料编码',
        prop: 'mtlNo'
      },
      {
        label: '材料名称',
        prop: 'mtlName'
      },
      {
        label: '材料颜色',
        prop: 'mtlColor'
      },
      {
        label: '规格',
        prop: 'mtlSpec'
      },
      {
        label: '单位',
        prop: 'mtlUnit'
      },
      {
        label: '数量',
        prop: 'qty'
      }
    ]
  },
  {
    Multistage: true,
    label: '材料替代后',
    children: [
      {
        label: '物料编码',
        prop: 'mtlNo2'
      },
      {
        label: '材料名称',
        prop: 'mtlName2'
      },
      {
        label: '材料颜色',
        prop: 'mtlColor2'
      },
      {
        label: '规格',
        prop: 'mtlSpec2'
      },
      {
        label: '单位',
        prop: 'mtlUnit2'
      },
      {
        label: '数量',
        prop: 'qty2'
      }
    ]
  }
])

const tableHeader10 = ref([
  {
    label: '物料编码',
    prop: 'mtlNo'
  },
  {
    label: '材料名称',
    prop: 'mtlName'
  },
  {
    label: '材料颜色',
    prop: 'mtlColor'
  },
  {
    label: '规格',
    prop: 'mtlSpec'
  },
  {
    label: '单位',
    prop: 'mtlUnit'
  },
  {
    label: '库存量',
    prop: 'stkQty'
  }
])

const findData = (count: any) => {
  if (count === '通用材料') {
    GeneralMaterialsQueryMethods()
    MaterialCategoryMethods()
    typeNumber.value = 1
    drawer1.value = true
  }
  if (count === '指令材料') {
    InstructionDataMethods()
    materialsClassificationMethods()
    FitSubmaterialDetailsMethods()
    typeNumber.value = 2
    drawer2.value = true
  }
  if (count === '型体材料') {
    BulkMaterialMethods()
    materialsClassificationMethods()
    FitSubmaterialDetailsMethods()
    typeNumber.value = 3
    drawer3.value = true
  }

  if (count === '贴合子材料') {
    InstructionDataMethods()
    materialsClassificationMethods()
    FitSubmaterialDetailsMethods()
    typeNumber.value = 2
    drawer2.value = true
  }

  if (count === '材料库') {
    materialDepotMethods()
    CommandMaterialEchoData()
    typeNumber.value = 4
    drawer5.value = true
  }

  if (count === '出库批处理') {
    if (BatchProcessingOutOfStorageMethodsPamrs.value.deptName === '' || BatchProcessingOutOfStorageMethodsPamrs.value.deptNo === '') {
      JMessage.warning('部门或者厂商不可为空必须选择')
    } else if (BatchProcessingOutOfStorageMethodsPamrs.value.slipReason === '') JMessage.warning('出库原因必须选择')
    else BatchProcessingOutOfStorageMethods()
  }

  if (count === '替代材料查询') {
    drawer7.value = true
    MaterialSubstitutionQueryMethods()
  }

  if (count === '整单删除') {
    if (slipNok.value === '') {
      JMessage.warning('请选择需要删除的数据')
    } else {
      handleClose3()
    }
  }

  if (count === '材料替代') {
    drawer6.value = true
    MaterialSubstitutionMatercListMethods()
    materialsClassificationMethods()
  }

  if (count === '置空') {
    clearFormList8()
  }
  if (count === '打印') {
    console.log(slipNoList3.value)
    if (slipNoList3.value.length === 0) {
      JMessage.warning('请点击需要打印的数据')
    } else if (slipNoList3.value[0].slipNo === null) {
      JMessage.warning('请选择有出库单号的进行打印')
    } else {
      printQRCode()
    }
  }
  if (count === '打印(连打)') {
    console.log(slipNoList3.value)
    if (slipNoList3.value.length === 0) {
      JMessage.warning('请点击需要打印的数据')
    } else if (slipNoList3.value[0].slipNo === null) {
      JMessage.warning('请选择有出库单号的进行打印')
    } else {
      printQRCode()
    }
  }
}

const clearFormList8 = () => {
  formList1.value.forEach((item) => {
    if (item.type === 'input') {
      item.inputValue = ''
    }
    if (item.type === 'select') {
      item.selectValue = ''
    }
    if (item.type === 'date') {
      item.dateValue = ''
    }
    // Add other conditions for different form item types
  })
}

// 统一调用接口
const interAceFunct = () => {
  DetailsToBeReleasedMethods()

  OtherMaterialDeliveryDetailsMethods()

  ReasonForDeliveryMethods()

  VendorQueryDateList()

  DepartmentAllInquiryMethods()
}

// 用户信息
const userInfo = ref()

onMounted(() => {
  interAceFunct()

  let userInf = sessionStorage.getItem('userInfo')

  userInfo.value = JSON.parse(userInf!)
})
</script>

<style lang="less" scoped>
h1 {
  font-size: 16px;
}

.mr10 {
  margin-left: 10px;
}
</style>
